<template>
  <header class="header">
      <h1>todos</h1>
      <input @keydown.enter="hAdd" v-model.trim="taskname" class="new-todo" placeholder="请输入任务名称" autofocus />
    </header>
</template>

<script>
export default {
  name: 'VueDay3TodoHeader',

  data() {
    return {
      taskname:'',
      
    };
  },



  methods: {
    hAdd() {
      // 非空校验
      if(this.taskname === '') return
       this.$emit('addTask',this.taskname)
      //清空输入框
      this.taskname = ''

    }
   
    
  },
};
</script>

<style lang="scss" scoped>

</style>